#ifndef _OI_PLSCANNERCORE_DYNAMICSPLINEVIEW_H_
#define _OI_PLSCANNERCORE_DYNAMICSPLINEVIEW_H_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        class DynamicSplineChart;

        class OI_PLSCANNER_CORE_API DynamicSplineView : public QGraphicsView
        {
            Q_OBJECT

        public:
            DynamicSplineView(const QStringList splines, QWidget *parent = Q_NULLPTR);
            ~DynamicSplineView();

        public:
            void zoomFit();

            void setSplines(QStringList splines);

            QStringList splines() const;

            DynamicSplineChart* chart();

            void setLimit(const double upper, const double lower);

            void run(bool flag);

            void toCurrent();

            void update();

            void setFormular(const QString name);

            QString formular() const;

        public:
            virtual QMap<QString, QList<QPointF>> loadData(const QDateTime from, const QDateTime end) = 0;
            virtual void addData(const qreal dt,  QMap<QString, qreal> data) = 0;

        public:
            virtual void resizeEvent(QResizeEvent *event);
            virtual void wheelEvent(QWheelEvent *event);
            virtual void mousePressEvent(QMouseEvent *event);
            virtual void mouseMoveEvent(QMouseEvent* event);
            virtual void mouseReleaseEvent(QMouseEvent* event);
            virtual void mouseDoubleClickEvent(QMouseEvent* event);
            virtual void paintEvent(QPaintEvent *event);

        public slots:
            void onTimeout();
            void onChartFlash();

        private:
            OI_DISABLE_COPY(DynamicSplineView);
            OI_DECLARE_IMPL(DynamicSplineView);
        };

    }
}


#endif
